<?php  
header("Content-type:text/html; Charset=utf-8");

fanyi("hello");
  function fanyi($yuanwen)
    {
    	
    	$yuanwen=get_utf8_string($yuanwen);
    	//$content = file_get_contents("http://fanyi.youdao.com/openapi.do?keyfrom=taolianjie&key=206560646&type=data&doctype=xml&version=1.1&q=".$yuanwen);
    	$doc = new DOMDocument();
$doc->load("http://fanyi.youdao.com/openapi.do?keyfrom=taolianjie&key=206560646&type=data&doctype=xml&version=1.1&q=".$yuanwen); //读取xml文件

$youdaos = $doc->getElementsByTagName( "youdao-fanyi" ); //取得humans标签的对象数组

foreach( $youdaos as $youdao )
{
$paragraphs = $youdao->getElementsByTagName( "paragraph" ); //取得name的标签的对象数组
$paragraph = $paragraphs->item(0)->nodeValue; //取得node中的值，如<name> </name>
$paragraph=get_utf8_string($paragraph);

}
echo $paragraph;
}
function get_utf8_string($content) {    
	//  将一些字符转化成utf8格式   
	 $encoding = mb_detect_encoding($content, array('ASCII','UTF-8','GB2312','GBK','BIG5'));  
	   return  mb_convert_encoding($content, 'utf-8', $encoding);}

?>